﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Data;
using Microsoft.TeamFoundation.WorkItemTracking.Client;

namespace WIAssistant
{
    [ValueConversion(typeof(double), typeof(String))]
    public class VisibilityToBooleanConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter,System.Globalization.CultureInfo culture)
        {
            bool result = MainMediator.Instance.VisibilityOfWorkItemColumnTitles == Visibility.Visible;

            bool invertLogic = false;
            if (parameter != null)
                invertLogic = (bool)parameter;

            if (invertLogic)
                return ! result;
            else
                return result;
            
        }
        public object ConvertBack(object value, Type targetType,object parameter,System.Globalization.CultureInfo culture)
        {
            bool invertLogic = false;
            if (parameter != null)
                invertLogic = (bool)parameter;

            bool input = (bool) value;
            if (invertLogic)
                input = !input;

            if (input)
                return Visibility.Visible;
            else
                return Visibility.Collapsed; 
        }

    }
}
